{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1afd17ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "from 写码 import 写码\n",
    "\n",
    "写码()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e24390b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "的一是不了在我人这大上中来地和说为也可道而得能都如行\n"
     ]
    }
   ],
   "source": [
    "from 算码 import 设置一简 \n",
    "\n",
    "一简 = 设置一简()\n",
    "print(一简)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4a78067a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'kem': ['沐'], 'bks': ['弘', '隶'], 'udk': ['扣'], 'ccc': ['烛'], 'wgyx': ['鲸'], 'pss': ['趟'], 'tqem': ['裹']}\n"
     ]
    }
   ],
   "source": [
    "from 算码 import 设置二简, 设置三简\n",
    "from 统计 import 检测全码重\n",
    "\n",
    "设置二简(0.1, 0.1, 1)\n",
    "设置三简()\n",
    "\n",
    "重码 = 检测全码重(3000)\n",
    "print(重码)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c97d3ab9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "隶沐邑猝驭"
     ]
    }
   ],
   "source": [
    "from 数据库 import 获取会话, 虎码\n",
    "from sqlalchemy import select, desc\n",
    "\n",
    "\n",
    "新增二简 = ['售', '裸', '鼠', '虫', '凉', '录', '寸', '众', '尚', '森', '命', '味', '杨', '碧', '裙', '瓣', '婿', '笋', '弩', '严', '闻']\n",
    "删除二简 = ['损', '雷', '路', '居', '待', '始', '湖', '从', '步', '林', '合', '哪', '校', '左', '雪', '戚', '群', '箫', '怒', '亚', '敢']\n",
    "新增三简 = ['损', '待', '始', '湖', '粮', '哪', '校', '戚', '群', '箫', '怒', '亚', '敢']\n",
    "删除三简 = ['損', '蹚', '魼', '㗠', '泥', '栴', '𠯎', '窔', '墬', '蹙', '君', '簘', '孥', '亞', '憨']\n",
    "\n",
    "\n",
    "with 获取会话() as 会话:\n",
    "    表 = 会话.execute(\n",
    "        select(虎码)\n",
    "        .where(虎码.字符.in_(set().union(删除二简, 删除三简, 新增二简, 新增三简)))\n",
    "    ).scalars()\n",
    "    for 行 in 表:\n",
    "        if 行.字符 in 删除二简:\n",
    "            行.二简 = None\n",
    "        if 行.字符 in 删除三简:\n",
    "            行.三简 = None\n",
    "        if 行.字符 in 新增二简:\n",
    "            行.二简 = 行.全码[:2]\n",
    "        if 行.字符 in 新增三简:\n",
    "            行.三简 = 行.全码[:3]\n",
    "\n",
    "\n",
    "重码 = 检测全码重(3500)\n",
    "with 获取会话() as 会话:\n",
    "    表 = 会话.execute(\n",
    "        select(虎码)\n",
    "        .where(虎码.字符.in_(set().union(*重码.values())))\n",
    "        .order_by(desc(虎码.频数))\n",
    "    ).scalars()\n",
    "    for 行 in 表:\n",
    "        print(行.字符, end='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6edc096f",
   "metadata": {},
   "outputs": [],
   "source": [
    "from 出码 import 出码\n",
    "\n",
    "出码()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
